/**
 * create by young (young2f@outlook.com) on 2020/12/4
 */
'use strict';
const model = require('../base/tModelBase');
const _ = require('lodash');
module.exports = app => {
  const mongoose = app.mongoose;
  const schema = mongoose.Schema;
  const connect = app.mongooseDB.get('pmcBus');
  const json = {
    date: { type: Date, _type: 'date', title: '登记日期', required: true , enableArea: [
        'table'
      ]},
    name: { type: String, _type: 'string', title: '项目名称', required: true, enableArea: [
        'table'
      ] },
    code: { type: String, _type: 'code', title: '编码', required: true },
    customerName: { type: String, _type: 'string', title: '客户名称', required: true, enableArea: [
        'table'
      ] },
    contacts: { type: String, _type: 'string', title: '联系人' , enableArea: [
        'table'
      ]},
    phone: { type: String, _type: 'string', title: '联系电话', enableArea: [
        'table'
      ] },
    salesman: { type: String, _type: 'string', title: '负责业务员', required: true, enableArea: [
        'table'
      ] },
    addr: {
      type: Array, _type: 'array', title: '地址', enableArea: [

      ],
      cols: [
        { type: String, _type: 'string', key:'addr',title: '地址', editable: true },
        { type: String, _type: 'string', key:'contacts',title: '联系人', editable: true }
      ]
    },
    detail: {
      type: Array, _type: 'array', title: '采购明细', enableArea: [

      ],
      cols: [
        { type: String, _type: 'string', key:'detail',title: '明细记录', editable: true }
      ]
    },
    progress: {
      type: Array, _type: 'array', title: '进度',
      cols: [
        { type: String, _type: 'string',key:'progress', title: '进度记录' , editable: true}
      ], enableArea: [

      ]
    },
    isNom: { type: Boolean, _type: 'boolean', title: '是否常规标', enableArea: [
        'table'
      ] },
    isBid: { type: Boolean, _type: 'code', title: '是否投标', enableArea: [
        'table'
      ] },
    bidFileList: { type: Array, _type: 'fileList', title: '截图' },
    result: { type: Boolean, _type: 'code', title: '结果反馈（是否中标）', enableArea: [
        'table'
      ] },
    resultFileList: { type: Array, _type: 'fileList', title: '截图' },
  };
  const _model = _.cloneDeep(model);
  _.assign(_model, json);
  const _schema = new schema(
    _model,
    { timestamps: { createdAt: 'createdTs', updatedAt: 'updatedTs' } }
  );
  return connect.model('DicBid', _schema);
};
